package 多线程;

import java.util.concurrent.TimeUnit;

public class Ressource1 {
    private Object syncObject1 = new Object();
    private Object syncObject2 = new Object();
    public void f(){
        System.out.println(Thread.currentThread().getName()+"not  yuxing");
        synchronized (this){
            for (int i = 0; i <5 ; i++) {
                System.out.println(Thread.currentThread().getName()+"yuxing");
                try{
                    TimeUnit.SECONDS.sleep(2);
                }catch (InterruptedException e ){
                    e.printStackTrace();
                }
            }
        }
    }
    public void g(){
        System.out.println(Thread.currentThread().getName()+"not yuxing");
        synchronized (syncObject1) {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + "2");
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        }

            Ressource1 resource = new Ressource1();
        {
            Ressource1 resourc = new Ressource1();
        }


        }
}
